<template>
  <div id="app">
    年纪：{{$store.state.age}}
    <br>
    getters年纪：{{$store.getters.getAge}}
    <button @click="onAdd">同步 增加</button>
    <button @click="onReduce">异步 减少</button>
  </div>
</template>

<script>
export default {
  name: 'app',
  created() {
//    console.log('app', this.$store);
    setTimeout(() => {
      this.$store.state.age = 100;
    }, 1000);
  },
  methods: {
    onAdd() {
      this.$store.commit('addAge', 10);
    },
    onReduce() {
      this.$store.dispatch('asyncReduce', 10);
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
